package cn.iocoder.yudao.module.product.spu.vo;

import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.validation.InEnumValue;
import cn.iocoder.yudao.module.api.dine.enums.DineAttributeEnum;
import cn.iocoder.yudao.module.api.product.DictTypeConstants;
import cn.iocoder.yudao.module.api.product.sku.dto.AdminPriceRespDTO;
import cn.iocoder.yudao.module.api.product.spu.enums.ProductPriceModeEnum;
import cn.iocoder.yudao.module.api.product.spu.enums.ProductSpuRecommendEnum;
import cn.iocoder.yudao.module.api.shop.info.dto.ShopInfoDTO;
import cn.iocoder.yudao.module.product.sku.vo.ProductSkuRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Schema(description = "管理后台 - 产品 SPU Response VO")
@Data
public class ProductSpuRespVO extends AdminPriceRespDTO {

    @Schema(description = "产品类型，可根据主营类目转换得来，如：mall、food、hotel", requiredMode = Schema.RequiredMode.REQUIRED, example = "mall")
    private String type;

    @Schema(description = "店铺编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
    private Long shopId;

    @Schema(description = "店铺信息")
    private ShopInfoDTO shop;

    @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "优艺尚  舒柔云貂绒毯\tU22-T008")
    private String name;

    @Schema(description = "关键字", example = "毛毯,休闲毯")
    private String keyword;

    @Schema(description = "产品简介", example = "采用精选云貂绒面料，手感细腻，柔软亲肤，给睡眠睡时放松惬意，柔软的肌肤触感，让整个冬天倍感温暖。")
    private String introduction;

    @Schema(description = "产品详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "清凉小短袖详情")
    private String description;

    @Schema(description = "行业类目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long platformCategoryId;

    @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long categoryId;

    @Schema(description = "产品品牌编号", example = "1")
    private Long brandId;

    @Schema(description = "产品品牌名称", example = "荣耀")
    private String brandName;

    @Schema(description = "产品封面图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.example.com/xx.png")
    private String picUrl;

    @Schema(description = "产品轮播图", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<String> sliderPicUrls;

    @Schema(description = "排序序号", example = "1")
    private Integer sort;

    @Schema(description = "产品状态：-1-回收站、0-已下架、1-已上架、2-待审核", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @DictFormat(DictTypeConstants.PRODUCT_SPU_STATUS)
    private Integer status;

    @Schema(description = "单位名称", example = "套")
    private String unitName;

    @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
    private Boolean specType;

    @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000")
    private Integer stock;

    @Schema(description = "SKU 数组")
    private List<ProductSkuRespVO> skus;

    public List<ProductSkuRespVO> getSkus() {
        if (skus == null) {
            skus = new ArrayList<>();
        }
        return skus;
    }

    @Schema(description = "计价模式：1-按单品计价、2-按称量计价")
    @InEnumValue(ProductPriceModeEnum.class)
    private Integer priceMode;

    @Schema(description = "配送类型/服务方式数组：0-无、1-快递发货、2-到店自提、3-同城配送、4-现场核销、5-上门服务", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private List<Integer> deliveryTypes;

    @Schema(description = "物流配置模板编号，快递发货是需要提供", example = "111")
    private Long deliveryTemplateId;

    @Schema(description = "推荐类型：0-无、1-精选、2-爆款、3-新品、4-补贴", example = "0")
    @InEnumValue(ProductSpuRecommendEnum.class)
    private Integer recommend;

    @Schema(description = "是否置顶", example = "false")
    private Boolean isSticky;

    @Schema(description = "是否积分产品", example = "false")
    private Boolean isIntegral;

    @Schema(description = "赠送积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "111")
    private Integer giveIntegral;

    @Schema(description = "是否分佣产品", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
    private Boolean isBrokerage;

    @Schema(description = "起购数量/起批数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer limitMinQuantity;

    @Schema(description = "限购数量", example = "999")
    private Integer limitMaxQuantity;

    @Schema(description = "每次加购数量", example = "1")
    private Integer stepQuantity;

    @Schema(description = "产品销量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000")
    private Integer salesCount;

    @Schema(description = "虚拟销量", example = "66")
    private Integer virtualSalesCount;

    @Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "888")
    private Integer browseCount;

    @Schema(description = "购买须知", example = """
            {"after_sale": "未拆封、不影响二次销售的情况下，支持7天无理由，邮费自理。质量问题请提供面单和内容物照片。", "delivery_time": "48小时(周末、节假日延后)", "special_version": "无运费险!订单已发货状态即表示已打包，非我方原因要拒收或拦载退款，可能需扣除运费相应的发货运费。", "delivery_expressage": "普通快递随机"}
            """)
    private String guidance;

    @Schema(description = "标签，英文逗号分隔")
    private List<String> labels;

    @Schema(description = "菜肴属性：0-无、1-主食、2-荤菜、3-素菜、4-汤、5-调料、6-饮品、7-水果、20-锅底、50-套餐、98-餐盒、99-备注")
    @InEnumValue(DineAttributeEnum.class)
    private Integer dishAttribute;
    @Schema(description = "菜肴属性：0-无、1-主食、2-荤菜、3-素菜、4-汤、5-调料、6-饮品、7-水果、20-锅底、50-套餐、98-餐盒、99-备注")
    private String dishAttributeName;

    @SuppressWarnings("unused")
    public String getDishAttributeName() {
        if (dishAttributeName == null) {
            return DineAttributeEnum.getByValue(getDishAttribute()).getName();
        }
        return dishAttributeName;
    }

}
